package com.dongdongshop.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

@Configuration
public class FreemarkerConfig {

    @Value("${myfreemarker.templateLoaderPath}")
    private String path;

    @Value("${myfreemarker.defaultEncoding}")
    private String Encoding;

    @Bean
    public FreeMarkerConfigurer freeMarkerConfigurer(){
        //创建对象
        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();

        //第二步：设置模板文件所在的路径。
        configurer.setTemplateLoaderPath(path);

//        第三步：设置模板文件使用的字符集。一般就是 utf-8.
        configurer.setDefaultEncoding(Encoding);


        return configurer;
    }
}
